<template>
  <el-card>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>基础信息</el-breadcrumb-item>
    </el-breadcrumb>

    <el-row>
      <el-col :span="6"
        ><div class="grid-content bg-purple-dark">
          <template>
          <el-image
            style="width: 50px; height: 50px; margin-bottom: -4px"
            :src= user.userImg
          >
          </el-image>
        </template></div>
        <div class="grid-content1 bg-purple-dark">{{ user.userName }}</div>
      </el-col>
      <el-col :span="4"
        ><div class="grid-content2 bg-purple">id</div>
        <div class="grid-content2 bg-purple">状态</div>
        <div class="grid-content2 bg-purple">注册时间</div>
      </el-col>
      <el-col :span="5"
        ><div class="grid-content3 bg-purple">{{ user.userId }}</div>
        <div class="grid-content3 bg-purple">{{ user.userStatus }}</div>
        <div class="grid-content3 bg-purple">{{ user.userCreatedTime }}</div>
      </el-col>
      <el-col :span="4"
        ><div class="grid-content2 bg-purple">手机号</div>
        <div class="grid-content2 bg-purple">最近登录时间</div>
        <div class="grid-content2 bg-purple"></div>
      </el-col>
      <el-col :span="5"
        ><div class="grid-content3 bg-purple">{{ user.userTel }}</div>
        <div class="grid-content3 bg-purple">{{ user.userLoginTime }}</div>
        <div class="grid-content3 bg-purple"></div>
      </el-col>
    </el-row>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>账户信息</el-breadcrumb-item>
    </el-breadcrumb>
    <el-row>
      <el-col :span="4"
        ><div class="grid-content4 bg-purple-dark">绑定车辆数</div>
        <div class="grid-content3 bg-purple-dark">
          {{ userAcc.accCarsBound }}
        </div>
      </el-col>
      <el-col :span="4"
        ><div class="grid-content4 bg-purple-dark">订单数量</div>
        <div class="grid-content3 bg-purple-dark">
          {{ userAcc.accOrderCount }}
        </div>
      </el-col>
      <el-col :span="4"
        ><div class="grid-content4 bg-purple-dark">消费金额</div>
        <div class="grid-content3 bg-purple-dark">{{ userAcc.accSpend }}</div>
      </el-col>
      <el-col :span="4"
        ><div class="grid-content4 bg-purple-dark">未缴费订单</div>
        <div class="grid-content3 bg-purple-dark">
          {{ userAcc.accUnpaidOrderCount }}
        </div>
      </el-col>
      <el-col :span="4"
        ><div class="grid-content4 bg-purple-dark">代缴费金额</div>
        <div class="grid-content3 bg-purple-dark">{{ userAcc.accUnpaid }}</div>
      </el-col>
      <el-col :span="4"
        ><div class="grid-content4 bg-purple-dark"></div>
        <div class="grid-content3 bg-purple-dark"></div>
      </el-col>
    </el-row>
    <div class="bb">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>车辆情况</el-breadcrumb-item>
    </el-breadcrumb>
    <el-form :inline="true" :model="query">
      <el-form-item>
        <el-input
          v-model="query.carLicensePlate"
          placeholder="车牌号"
          :clearable="true"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="query.carBindTime"
          type="datetimerange"
          range-separator="至"
          start-placeholder="绑定日期"
          end-placeholder="绑定日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="loadCars"
          ><i class="el-icon-search"></i
        ></el-button>
      </el-form-item>
    </el-form>
    <el-table :data="carList" style="width: 100%">
      <el-table-column
        align="center"
        prop="licName"
        label="车牌号码"
        width="120"></el-table-column>
      <el-table-column
        align="center"
        prop="licType"
        label="车牌类型"
        width="100"></el-table-column>
      <el-table-column
        align="center"
        prop="totalNum"
        label="订单数量"
        width="90"></el-table-column>
      <el-table-column
        align="center"
        prop="nopayNum"
        label="待缴费订单"
        width="100"></el-table-column>
      <el-table-column
        align="center"
        prop="totalMoney"
        label="消费金额"
        width="100"></el-table-column>
      <el-table-column
        align="center"
        prop="nopayMoney"
        label="待缴费金额"
        width="100"></el-table-column>
      <el-table-column
        align="center"
        prop="createTime"
        label="绑定时间"
        width="180"></el-table-column>
    </el-table>
    
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="query.currentPage"
      :page-sizes="page.pageSizes"
      :page-size="query.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="page.total">
    </el-pagination>
    </div>
    <div class="cc">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <div class="aa"><el-breadcrumb-item>订单记录</el-breadcrumb-item></div>
    </el-breadcrumb>
    <el-form :inline="true" :model="query">
      <el-form-item>
        <el-input
          v-model="query.carLicensePlate"
          placeholder="订单号"
          :clearable="true"
          
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-input
          v-model="query.carLicensePlate"
          placeholder="车牌号"
          :clearable="true"
          
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="query.carBindTime"
          type="datetimerange"
          range-separator="至"
          start-placeholder="绑定日期"
          end-placeholder="绑定日期"
          
        >
        </el-date-picker>
      </el-form-item>
             <el-form-item >
              <el-select
                v-model="query1.orderStatus"
                placeholder="请选择"
                style="width: 100%"
                
              >
                <el-option
                  v-for="item in statusLsit"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="loadorderItem"
          >搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="orderItemList" style="width: 100%">
      <el-table-column
        align="center"
        prop="oiNo"
        label="订单编号"
        width="320"></el-table-column>
      <el-table-column
        align="center"
        prop="oiEndTime"
        label="提交时间"
        width="180"></el-table-column>
      <el-table-column
        align="center"
        prop="carLicensePlate"
        label="车牌号码"
        width="120"></el-table-column>
      <el-table-column
        align="center"
        prop="oiAmount"
        label="订单金额"
        width="100"></el-table-column>
      <el-table-column
        align="center"
        prop="orderStatus"
        label="订单状态"
        width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.orderStatus== 0">已支付</span>
          <span v-if="scope.row.orderStatus== 1">未支付</span>
          <span v-if="scope.row.orderStatus== 2">未确认</span>
          <span v-if="scope.row.orderStatus== 3">进行中</span>
          <span v-if="scope.row.orderStatus== 4">申诉中</span>
          <span v-if="scope.row.orderStatus== 5">已退款</span>
          <span v-if="scope.row.orderStatus== 6">已完成</span>
        </template>
        </el-table-column>
      <el-table-column
        align="center"
        prop="ptType"
        label="支付方式"
        width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.ptType== 1">微信</span>
          <span v-if="scope.row.ptType== 2">支付宝</span>
        </template>
        </el-table-column>

    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="query.currentPage"
      :page-sizes="page.pageSizes"
      :page-size="query.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="page.total1">
    </el-pagination>
    </div>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      user: {},
      uid: 0,
      userAcc: {},
      userAccList: [],
      carList: [],
      orderItemList:[],
      statusLsit:[
        {
          id:0,
          name:"已支付"
        },
        {
          id:1,
          name:"未支付"
        },
        {
          id:2,
          name:"未确认"
        },
        {
          id:3,
          name:"进行中"
        },
        {
          id:4,
          name:"申诉中"
        },
        {
          id:5,
          name:"已退款"
        },
      ],    
      query: {
        userId: 0,
        currentPage: 1, //代表当前页
        pageSize: 5, //代表每页显示多少条数据
        carLicensePlate: "",
        carBindTime: [],
      },
       query1: {
        userId: 0,
        currentPage: 1, //代表当前页
        pageSize: 5, //代表每页显示多少条数据
        orderno:"",
        licName:"",
        daterange:[],
        orderStatus:null
      },
      page: {
        pageSizes: [5, 10, 20, 50, 100], //下拉列表中的数组
        total: 0, //一共有多少条数据
        total1: 0,
      },
    };
  },
  methods: {
    loadUser() {
      this.uid = this.$route.query.uid;
      this.$axios.get("users/" + this.uid).then((res) => {
        this.user = res.data.data.user;
      });
    },
    loadUserAcc() {
      this.query.userId = this.$route.query.uid;
      this.$axios.post("users/queryLike", this.query).then((res) => {
        this.userAccList = res.data.data.userList;
        this.userAcc = this.userAccList[0];
      });
    },
    loadCars() {
      this.query.userId = this.$route.query.uid;
      this.$axios.post("TCars/selCarByUid", this.query).then((res) => {
        this.carList = res.data.data.carList;
        this.page.total = res.data.data.total;
      });
    },
    loadorderItem() {
      this.query1.userId = this.$route.query.uid;
      this.$axios.post("orderItems/selAllOrderByUid", this.query1).then((res) => {
        this.orderItemList = res.data.data.orderItemList;
        this.page.total1 = res.data.data.total;
      });
    },
    handleSizeChange(val) {
      //当每页数据改变时
      this.query.pageSize = val;
      this.query1.pageSize = val;
      this.loadCars();
    },
    handleCurrentChange(val) {
      //当点击页码时
      this.query.currentPage = val;
      this.loadCars();
    },
  },
  mounted() {
    this.loadUser();
    this.loadUserAcc();
    this.loadCars();
    this.loadorderItem();
  },
};
</script>
<style>
.el-row {
  margin-bottom: 20px;
  min-height: 100px;
}
.grid-content {
  border: 1px solid gray;
  height: 62px;
  text-align: center;
  border-block-end: 0;
  background-color: darkgray;
}
.grid-content1 {
  border: 1px solid gray;
  height: 62px;
  text-align: center;
  border-block-start: 0;
  background-color: darkgray;
}
.grid-content2 {
  border: 1px solid gray;
  height: 40px;
  text-align: center;
  line-height: 40px;
  background-color: darkgray;
}
.grid-content3 {
  border: 1px solid gray;
  height: 40px;
  text-align: center;
  line-height: 40px;
}
.grid-content4 {
  border: 1px solid gray;
  height: 40px;
  text-align: center;
  border-block-start: 0;
  background-color: darkgray;
}

.bb{
  border: 1px solid gray;
  
}
.cc{
  border: 1px solid gray;
   margin-top: 100px;
}

</style>